<?php
/*
 * @Author: your name
 * @Date: 2020-11-17 10:25:53
 * @LastEditTime: 2020-12-28 14:09:08
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /special/application/adminapiv3/controller/module_manage/netfilter/RuleLogController.php
 */
namespace app\adminapiv3\controller\module_manage\netfilter;

use app\adminapiv3\service\module_manage\netfilter\RuleLogService;

class RuleLogController extends NetfilterBaseController
{
    /**
     * @name: 日志列表
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-11-17 10:26:34
     */
    public function list (\think\Request $request)
    {
        $input = $request->only(['error_code','host_id'], 'post');

        $this->validate($input, 'RuleLog.list');
        
        $RuleLogService = new RuleLogService();
        $data = $RuleLogService->list($input);

        return $this->jsonOutPut($data);

    }

    /**
     * @name: 规则详情
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-11-18 10:59:34
     */
    public function info (\think\Request $request)
    {
        $input = $request->only(['id','host_id'], 'post');

        $this->validate($input, 'RuleLog.info');
        $RuleLogService = new RuleLogService();
        $data = $RuleLogService->info($input);

        return $this->jsonOutPut($data);
    }

    /**
     * @name: 规则回滚
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-11-17 10:26:51
     */
    public function reset (\think\Request $request)
    {
        $input = $request->only(['id','host_id','create_time','signature_code','os'], 'post');

        $this->validate($input, 'RuleLog.reset');
        
        $RuleLogService = new RuleLogService();
        $data = $RuleLogService->reset($input);

        //下发命令 查询规则列表
        $this->sendCommandToClient('netfilter','downloadRules');
        return $this->jsonOutPut($data);
    }
    
    /**
     * @name: 删除
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-11-17 10:26:51
     */
    public function delete (\think\Request $request)
    {
        $input = $request->only(['id','host_id'], 'post');

        $this->validate($input, 'RuleLog.reset');
        
        $RuleLogService = new RuleLogService();
        $data = $RuleLogService->delete($input);

        return $this->jsonOutPut($data);
    }
}